package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportVideoDeviceDto;
import com.yqg.protection.entity.VideoDevice;
import com.yqg.protection.mapper.VideoDeviceMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 15:50
 * description:
 */
@Component
public class VideoDeviceListener extends AnalysisEventListener<ImportVideoDeviceDto> {

    @Resource
    private VideoDeviceMapper videoDeviceMapper;

    @Override
    public void invoke(ImportVideoDeviceDto importVideoDeviceDto, AnalysisContext analysisContext) {
        VideoDevice videoDevice = new VideoDevice();
        BeanUtil.copyProperties(importVideoDeviceDto, videoDevice, true);
        videoDevice.setIsDelete(0);
        videoDeviceMapper.insert(videoDevice);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
